package com.wilmer.schedule.service.impl;

import java.util.List;

import com.wilmer.common.core.domain.entity.SysUser;
import com.wilmer.common.utils.DateUtils;
import com.wilmer.common.utils.SecurityUtils;
import com.wilmer.schedule.domain.vo.StudentListByCourseIdVO;
import com.wilmer.schedule.domain.vo.UserVO;
import com.wilmer.schedule.domain.vo.YwClassScheduleVO;
import org.apache.catalina.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.wilmer.schedule.mapper.YwClassScheduleMapper;
import com.wilmer.schedule.domain.YwClassSchedule;
import com.wilmer.schedule.service.IYwClassScheduleService;

/**
 * 课程管理Service业务层处理
 *
 * @author zl
 * @date 2024-04-10
 */
@Service
public class YwClassScheduleServiceImpl implements IYwClassScheduleService {
    @Autowired
    private YwClassScheduleMapper ywClassScheduleMapper;

    /**
     * 查询课程管理
     *
     * @param courseId 课程管理主键
     * @return 课程管理
     */
    @Override
    public YwClassSchedule selectYwClassScheduleByCourseId(Long courseId) {
        return ywClassScheduleMapper.selectYwClassScheduleByCourseId(courseId);
    }

    /**
     * 查询课程管理列表
     *
     * @param ywClassSchedule 课程管理
     * @return 课程管理
     */
    @Override
    public List<YwClassSchedule> selectYwClassScheduleList(YwClassSchedule ywClassSchedule) {
        ywClassSchedule.setDeptId(SecurityUtils.getLoginUser().getDeptId());
        return ywClassScheduleMapper.selectYwClassScheduleList(ywClassSchedule);
    }

    /**
     * 新增课程管理
     *
     * @param ywClassSchedule 课程管理
     * @return 结果
     */
    @Override
    public int insertYwClassSchedule(YwClassSchedule ywClassSchedule) {
        ywClassSchedule.setCreateTime(DateUtils.getNowDate());
        SysUser user = SecurityUtils.getLoginUser().getUser();
        ywClassSchedule.setDeptId(user.getDeptId());
        ywClassSchedule.setTeacherId(user.getUserId());
        return ywClassScheduleMapper.insertYwClassSchedule(ywClassSchedule);
    }

    @Override
    public int addStudent(YwClassScheduleVO ywClassScheduleVO) {
        return ywClassScheduleMapper.addStudent(ywClassScheduleVO);
    }

    @Override
    public int deleteStudent(YwClassScheduleVO ywClassScheduleVO) {
        return ywClassScheduleMapper.deleteStudent(ywClassScheduleVO);
    }

    @Override
    public List<UserVO> selectStudentUserByDeptId() {
        Long deptId = SecurityUtils.getDeptId();
        return ywClassScheduleMapper.selectStudentUserByDeptId(deptId);
    }
    @Override
    public List<StudentListByCourseIdVO> studentListByCourseId(Long courseId) {
        return ywClassScheduleMapper.studentListByCourseId(courseId);
    }
    /**
     * 修改课程管理
     *
     * @param ywClassSchedule 课程管理
     * @return 结果
     */
    @Override
    public int updateYwClassSchedule(YwClassSchedule ywClassSchedule) {
        ywClassSchedule.setUpdateTime(DateUtils.getNowDate());
        return ywClassScheduleMapper.updateYwClassSchedule(ywClassSchedule);
    }

    /**
     * 批量删除课程管理
     *
     * @param courseIds 需要删除的课程管理主键
     * @return 结果
     */
    @Override
    public int deleteYwClassScheduleByCourseIds(Long[] courseIds) {
        return ywClassScheduleMapper.deleteYwClassScheduleByCourseIds(courseIds);
    }

    /**
     * 删除课程管理信息
     *
     * @param courseId 课程管理主键
     * @return 结果
     */
    @Override
    public int deleteYwClassScheduleByCourseId(Long courseId) {
        return ywClassScheduleMapper.deleteYwClassScheduleByCourseId(courseId);
    }
}
